% OSL1
%
% Files
%   appendevent_v2                                    - APPENDEVENT
%   backup                                            - [ results_fnames ] = osl_run_first_level_epoched( oat )
%   bayes_pca                                         - [m_w, alpha, C, taus]=bayes_pca(x,Q,niters,dofs_lost)
%   bayes_pca_ss                                      - [m_w, alpha, C, taus]=bayes_pca(x,Q,niters,dofs_lost)
%   bluewhitered                                      - Blue, white, and red color map.
%   boxcox1                                           - BOXCOX: Box-Cox maximum-likelihood transformation to find the optimal power 
%   channelconnectivity                               - CHANNELCONNECTIVIY creates a NxN matrix that describes whether channels 
%   channelrepair                                     - FT_CHANNELREPAIR repairs bad or missing channels in MEG or EEG data by
%   cluster4d_batch                                   - cluster_stats=cluster4d_batch(S)
%   cluster4d_dist                                    - subfunction of cluster4d_batch
%   convert_back_to_time                              - Nsamples=109;yo=demean(randn(Nsamples,1)); NumUniquePts=ceil((Nsamples+1)/2); freq_indtest=2:25; fyo=fft(yo); fyo=fyo(freq_indtest);  y=convert_back_to_time(fyo,Nsamples, freq_indtest); sfigure;plot(y);ho;plot(yo,'r--')
%   convert_script_fingertap                          - convert_script(inputdir,working_dir,subjid,subjinitials,runnum)
%   convert_script_rsn                                - convert_script(inputdir,working_dir,subjid,subjinitials,runnum)
%   correct_ica_pvals                                 - correct_ica_pvals.m
%   correct_planar_grads                              - correct_planar_grads(filename)
%   correct_planar_grads_triux                        - correct_planar_grads_triux(filename,factor)
%   demo_coape_vs_acope                               - Why do we need to rectify:
%   detect_eyeblinks                                  - D = detect_eyeblinks(S)
%   exportfig                                         - Export a figure.
%   eyeblink_correct_detect                           - 
%   eyeblink_hb_correct_remove                        - eyeblink_hb_correct_remove(S)
%   fdr_correct_pvals                                 - fdr_correct_pvals.m
%   fetch_sens                                        - FT_FETCH_SENS mimics the behaviour of FT_READ_SENS, but for a FieldTrip
%   find_best_voxs_mean                               - 
%   find_erf_best_voxs_mean                           - 
%   freezeColors                                      - freezeColors  Lock colors of plot, enabling multiple colormaps per figure. (v2.3)
%   fslview                                           - fslview.m
%   ft_chantype                                       - determines for each individual channel what type of data it
%   ft_findcluster                                    - FINDCLUSTER returns all connected clusters in a 3 dimensional matrix
%   ft_prepare_vol_sens_fix                           - FT_PREPARE_VOL_SENS does some bookkeeping to ensure that the volume
%   ft_read_event_v2                                  - FT_READ_EVENT reads all events from an EEG/MEG dataset and returns
%   get_nii_spatial_res                               - 
%   get_voxel_recon_timecourse                        - [ dat wnorms wnorm wnorms_nai wnorm_nai ] = get_voxel_recon_timecourse( S )
%   get_voxel_recon_timecourse_vector                 - [ dat wnorms wnorm wnorms_nai wnorm_nai ] = get_voxel_recon_timecourse_vector( S )
%   glm_fast                                          - y = demean(randn(100,1))+s'*0.1+s2'*2;
%   glm_fast_for_meg                                  - [cope, varcope, coape, dof]=glm_fast_for_meg(y,x,pinvxtx,pinvx,cs,con)
%   hilbert_envelope_cc                               - 
%   identify_artefactual_components_auto              - osl_africa.m
%   identify_artefactual_components_manual            - osl_africa.m
%   identify_artefactual_components_manual_gui        - Create UI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   indchantype                                       - Method for getting channel indices based on labels and/or types
%   inside_contour                                    - 
%   makeStdTopo                                       - D - D object filename, or D object
%   max2d                                             - [indi indj]=max2d(X)
%   max3d                                             - [indi indj indk]=max2d(X)
%   mwgauss                                           - GAUSS   Creates a gaussian function
%   nearest_vec                                       - [ index, vec, dist ] = nearest_vec( vec_array, vec_to_find )
%   nii_quickread                                     - reads nifti files and converts from a volume to a matrix. 
%   nii_quicksave                                     - nii_quicksave.m
%   normalise_sensor_data                             - % normalise modalities using smallest eigenvalues or mean of eigs (i.e. the overall variance)
%   normalise_sensor_data_new                         - % normalise modalities using smallest eigenvalues 
%   nosl_forward_model                                - runs MEG forward model in SPM8 or SPM12
%   nosl_headmodel                                    - runs MEG coregistration and forward model in SPM8 or 
%   oat_consolidate_results                           - [ oat ] = oat_consolidate_results( oat )
%   oat_find_max_stats                                - [vox_ind_max time_ind_max freq_ind_max] = oat_find_max_stats(S)
%   oat_first_level_stats_report                      - report=oat_first_level_stats_report(oat,first_level_results)
%   oat_group_level_stats_report                      - report = oat_group_level_stats_report(oat,group_level_results)
%   oat_output_roi_stats                              - [stats_out,times]=oat_output_roi_stats( Sin )
%   oat_plot_roi_stats                                - [vox_coords vox_coords_times fig_handle fig_name] = oat_plot_glm_stats()
%   oat_plot_vox_stats                                - [fig_handle fig_name fig_title] = oat_plot_vox_stats(S)
%   oat_stats_combine_grads                           - 
%   oil_single_subject_maps                           - 
%   opt_consolidate_results                           - [ opt ] = opt_consolidate_results( opt )
%   opt_report_summary_plots                          - [opt, opt_report]=opt_report_summary_plots(opt, opt_report);
%   ortho_overlay_act                                 - ortho_overlay_act( S )
%   osl_africa                                        - osl_africa.m
%   osl_badchans                                      - omt_badchans
%   osl_brain_plot                                    - osl_brain_plot(fname,plot_type,slice_ind,vol,gridstep,bg_type, plot_name,plot_title,perc_thresh)
%   osl_braingraph                                    - Pretty graph plotting
%   osl_call_maxfilter                                - osl_call_maxfilter.m
%   osl_change_spm_eeg_data                           - [ D2 ] = osl_change_spm_eeg_data( Sc )
%   osl_channelrepair                                 - 
%   osl_channelrepairMEG                              - 
%   osl_check_bad_chans                               - [res fig_names fig_handles]=osl_check_bad_chans(S)
%   osl_check_eigenspectrum                           - Check the eigenspectrum for discontinuities introduced by MaxFilter and ICA preprocessing
%   osl_check_for_zeros                               - 
%   osl_check_oat                                     - oat = osl_check_oat(oat)
%   osl_check_oil                                     - oil = osl_check_oil(oil)
%   osl_check_opt                                     - opt = osl_check_opt(opt)
%   osl_cluster_perm_sensor_tf                        - [corrp group_tstats group_copes] = osl_cluster_perm_sensor_tf(S)
%   osl_cluster_permutation_testing                   - [ results ] = osl_cluster_permutation_testing( S )
%   osl_clustertf                                     - [corrp tstats] = osl_clustertf(c,thresh,nP,con,varcope_time_smooth_std,tres)
%   osl_concat_spm_eeg_chans                          - [ D2 ] = osl_concat_spm_eeg_chans( Sc )
%   osl_concat_subs                                   - osl_concat_subs.m
%   osl_conn_hilbert_envelope                         - 
%   osl_conn_hilbert_plv                              - PLV: Measuring Phase Synchrony in Brain Signals. Jean-Philippe Lachaux et al, HBM 1999
%   osl_convert_script                                - [D fname] = osl_convert_script(Sin)
%   osl_convert_trialwise_to_fieldtrip                - GJW and MP
%   osl_correct_meeg_paths                            - Corrects hidden hard-coded paths in spm object to those in D.path or
%   osl_detect_badchannel                             - 
%   osl_detect_badevent                               - 
%   osl_detect_badevent_v2                            - [Dx,fig_handles]=osl_detect_badevent_v2(S)
%   osl_edit_fid                                      - Interactive tool to remove rogue headshape points stored in D.fiducials
%   osl_epoch                                         - [ D_epoched goodtrials ] = osl_epoch( S )
%   osl_example_africa                                - OSLWORKSHOPS - DEMONSTRATING HOW TO CLEANUP DATA USING OSLVIEW & AFRICA
%   osl_example_beamformer_oat                        - PRACTICAL: OAT BEAMFORMING
%   osl_example_beamformer_oat_eeg                    - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_beamformer_oat_parametric_eeg         - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_beamformer_oat_play                   - This practical will work with a single subject's data from an emotional
%   osl_example_connectivity_oat                      - % SETUP THE MATLAB PATHS
%   osl_example_continuous_oat                        - PRACTICAL: OAT CONTINUOUS BEAMFORMER CONTRAST
%   osl_example_CTF_data_conversion_and_preprocessing - OSL CTF Data Conversion & Preprocessing Script Example 
%   osl_example_group_oat                             - get data from: www.fmrib.ox.ac.uk/~woolrich/faces_group_data.tar.gz
%   osl_example_group_sensorspace_oat                 - % SETUP THE MATLAB PATHS
%   osl_example_oil                                   - OSL Task-postive ICA Example using
%   osl_example_oil_resting_state                     - OSL WORKSHOPS - Resting State Group Analysis Using OIL.
%   osl_example_oil_task                              - OSL Task-postive ICA Example using
%   osl_example_preprocessing_eeg                     - In this practical we will work with a single subject's EEG data
%   osl_example_preprocessing_manual                  - PRACTICAL: MANUAL PREPROCESSING 
%   osl_example_preprocessing_opt                     - PRACTICAL: AUTOMATED PREPROCESSING IN OPT
%   osl_example_preprocessing_scanner_artefacts       - % SETUP THE MATLAB PATHS
%   osl_example_ROI_network_analysis                  - Example ROI network analysis
%   osl_example_sensorspace_continuous_oat            - Practical: Sensorspace Continuous OAT
%   osl_example_sensorspace_oat                       - Practical: Sensorspace OAT
%   osl_example_sensorspace_oat_eeg                   - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_sensorspace_oat_meg                   - In this practical we will work with a single subject's data from an
%   osl_example_sensorspace_oat_parametric_eeg        - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_sensorspace_oat_parametric_tf_eeg     - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_sensorspace_oat_tf                    - Practical: Sensorspace Time-Frequency
%   osl_example_sensorspace_oat_tf_eeg                - In this practical we will work with a single subject's EEG dat and perform an ERF
%   osl_example_sensorspace_oat_tf_meg                - In this practical we will work with a single subject's data from an
%   osl_example_sensorspace_oat_tf_multitaper         - In this practical we will work with a single subject's data from an
%   osl_example_simulate_MEG_data                     - OSL_EXAMPLE_SIMULATE_MEG_DATA
%   osl_example_sourcespace_erf_oat_full_pipeline     - This is a TEMPLATE script for running the OHBA recommended 
%   osl_example_using_maxfilter                       - OSLWORKSHOPS - DEMONSTRATING HOW TO REMOVE SCANNER ARTEFACTS
%   osl_forward_model                                 - runs MEG or EEG forward model
%   osl_get_oat_sensordata                            - [ D ] = osl_get_oat_sensordata( oat_results )
%   osl_get_recon_timecourses                         - results = osl_get_recon_timecourses( source_recon_results )
%   osl_get_source_power_in_mask                      - average source power within a masked region
%   osl_ica_maps_group_stats                          - osl_ica_maps_group_stats
%   osl_ica_preproc                                   - osl_ica_preproc.m
%   osl_inverse_batch                                 - [source_recon_results ] = osl_inverse_batch( S )
%   osl_lightbox                                      - 
%   osl_load_oat                                      - [oat] = osl_load_oat(oatdir, first_level_name, subject_level_name, group_level_name)
%   osl_load_oat_results                              - res=osl_load_oat_results.m(oat, fname)
%   osl_load_oil                                      - load OIL structure with the file name fname
%   osl_load_oil_results                              - res=osl_load_oil_results.m(oil, fname)
%   osl_load_opt                                      - load opt structure
%   osl_load_opt_results                              - res=osl_load_opt_results.m(opt, fname)
%   osl_make_standalone                               - Compile OSL as a standalone executable using the MATLAB compiler
%   osl_make_surf_movie                               - osl_make_surf_movie(S)
%   osl_merge_first_levels                            - [oat] = firstLevelSessCombine(sessionInds,oat)
%   osl_mnicoords2ind                                 - [ ind ] = osl_mnicoords2ind(mni_coords, mni_res)
%   osl_mnicoords2mnimask                             - [ fname_out ] = osl_mnicoords2mnimask.m( mni_coords_in, gridstep, fname, resamp_gridstep )
%   osl_mnimask2mnicoords                             - [ mni_coords xform ] = osl_mnimask2mnicoords(mask)
%   osl_movavg                                        - Moving window averaging
%   osl_movcorr                                       - Moving window correlation
%   osl_network_analysis                              - ROI correlation and partial correlation matrices
%   osl_neuromag_grad_baseline_correction             - 
%   osl_oat_plot_hmm_states                           - fig_handles=osl_oat_plot_hmm_states( oat )
%   osl_output_roi_stats                              - [stats_out,times]=osl_output_roi_stats( Sin )
%   osl_perform_ica                                   - osl_perform_ica.m
%   osl_prepare_oat_batch                             - function bashfilename = osl_prepare_oat_batch(oat,deploy,maxRam)
%   osl_reassemble_oat                                - Takes an oat computed in parallel, and reassembles it (for subject and
%   osl_reduce_data_to_visualize                      - Takes a full erf [voxels x time] dataset or a tf [voxels x time x freq]
%   osl_reject_bad_epoch_trials                       - [D_epoched good_trial_starts] = osl_reject_bad_epoch_trials( S )
%   osl_rejectvisual                                  - D = osl_rejectvisual(S)
%   osl_remove_jumps                                  - remove discontinuities from MEG raw signal
%   osl_render4D                                      - Creates a surface rendering of a 4D nifti file and saves as dense time series
%   osl_render_vols_to_surf                           - res = osl_render_vols_to_surf(S)
%   osl_report_add_sub_report                         - 
%   osl_report_print_figs                             - 
%   osl_report_set_figs                               - 
%   osl_report_setup                                  - 
%   osl_report_write                                  - 
%   osl_resample_nii                                  - output_fname = osl_resample_nii(input_fname, output_fname, out_gridstep, interp)
%   osl_resolve_sign_ambiguity                        - 
%   osl_run_first_level                               - [results_fnames results] = osl_run_first_level( oat )
%   osl_run_first_level_continuous_state              - [ results_fnames ] = osl_run_first_level_continuous( oat )
%   osl_run_first_level_continuous_state_new          - [ results_fnames ] = osl_run_first_level_continuous( oat )
%   osl_run_first_level_continuous_state_vector_seed  - [ results_fnames ] = osl_run_first_level_continuous( oat )
%   osl_run_first_level_epoched_state                 - [ results_fnames ] = osl_run_first_level_epoched( oat )
%   osl_run_first_level_epoched_state_new             - [ results_fnames ] = osl_run_first_level_epoched( oat )
%   osl_run_first_level_hmm                           - [ results_fnames ] = osl_run_first_level( oat )
%   osl_run_first_level_ica                           - [ oil ] = osl_run_first_level_ica( oil )
%   osl_run_group_level                               - [ results_fnames ] = osl_run_group_level( oat )
%   osl_run_group_level_ica                           - [ oil ] = osl_run_group_level_ica ( oil )
%   osl_run_oat                                       - oat = osl_run_oat(oat)
%   osl_run_oil                                       - oil = osl_run_ica(oil)
%   osl_run_opt                                       - opt=osl_run_opt(opt)
%   osl_run_parallel_oat                              - function runOSCoat(oat,osldir)
%   osl_run_source_recon_inverse                      - results_fnames=osl_run_source_recon_beamform(oat)
%   osl_run_source_recon_sensorspace                  - setup sensor space data
%   osl_run_subject_level                             - [ results_fnames ] = osl_run_subject_level( oat )
%   osl_save_nii_ica_maps                             - osl_save_nii_ica_maps.m
%   osl_save_nii_stats                                - [statsdir,times]=osl_save_nii_stats( Sin )
%   osl_save_nii_stats.old                            - [statsdir,times]=osl_save_nii_stats( Sin )
%   osl_save_oat                                      - [oat] = osl_save_oat(oat)
%   osl_save_oat_results                              - osl_save_oat_results( oat, oat_stage_results )
%   osl_save_oil                                      - [oil] = osl_save_oil(oil)
%   osl_save_opt_results                              - osl_save_opt_results( opt, opt_results )
%   osl_save_spm_stats                                - [D_tstat, D_cope] = osl_save_spm_stats( Sin )
%   osl_setup_oil                                     - oil = osl_setup_oil_for_ica(S)
%   osl_simulate_MEG_data                             - simulates MEG sensor data
%   osl_single_subject_maps                           - osl_single_subject_maps.m
%   osl_spm_resample                                  - this is to downsample the time domain signal.  It's the spm
%   osl_startup                                       - 
%   osl_stats_multiplotER                             - [cfg, dats, fig_handle]=osl_stats_multiplotER(S)
%   osl_stats_multiplotTFR                            - [cfg, dats, fig_handle]=osl_stats_multiplotTFR(S)
%   osl_test_script                                   - matlab < /Users/woolrich/homedir/matlab/osl1.2.beta.15/osl_test_script.m > /Users/woolrich/homedir/matlab/osl_testdata_dir/test_output/log.txt 2>&1 &
%   osl_test_script_group                             - 
%   osl_test_script_group_full                        - 
%   osl_test_script_oil                               - 
%   osl_test_script_recon                             - 
%   osl_test_script_sensorspace                       - 
%   osl_tf_transform                                  - [ dattf ] = osl_tf_transform( S , dat )
%   osl_tracker_read_file                             - TRACKER_READ_FILE read in the tab delimitated report from Eye Link Viewer

%   pinv_plus                                         - Modified Pseudoinverse which allows a specified
%   plot_hmm                                          - [fig_handles fig_names fig_titles]=plot_hmm( S )
%   plot_vector                                       - PLOT_VECTOR
%   post_bf_freq2time                                 - Takes Beamformer Output and converts from frequency domain to time
%   prepare_layout                                    - creates a 2-D layout of the channel locations. This layout
%   read_trigger_v2                                   - READ_TRIGGER extracts the events from a continuous trigger channel
%   reconstruct_from_weights                          - reconstruct_from_weights.m
%   run_multistart_hmm                                - 
%   runcmd                                            - 
%   save_raw_tra_to_D                                 - SAVE_RAW_TRA_TO_D
%   setup_beamformer_designmatrix                     - creates a GLM design matrix
%   setup_group_oat_example                           - % SETUP THE MATLAB PATHS
%   setup_mask_indices                                - [ mask_indices_in_lower_level ] = setup_mask_indices( Sin )
%   setup_multisession_group_oat_example              - % SETUP THE MATLAB PATHS
%   setup_std_masks                                   - 
%   shadedErrorBar                                    - function H=shadedErrorBar(x,y,errBar,lineProps,transparent)
%   spm_eeg_convert_v2                                - Convert various M/EEG formats to SPM8 format
%   spm_eeg_convert_v2_old                            - Main function for converting different M/EEG formats to SPM8 format.
%   spm_eeg_convert_v3                                - TC this file is a modified version of spm_eeg_convert
%   spm_eeg_downsample_v2                             - Downsample M/EEG data
%   spm_eeg_epochs_v2                                 - Epoching continuous M/EEG data
%   spm_eeg_filter_v2                                 - Filter M/EEG data
%   spm_eeg_ft_artefact_visual_v2                     - Function for interactive artefact rejection using Fieldtrip
%   spm_eeg_inv_checkdatareg_3Donly                   - Display of the coregistred meshes and sensor locations in MRI space for
%   spm_eeg_reduce                                    - Apply data reduction to M/EEG dataset
%   spm_eeg_reduce_pca_adapt                          - Plugin for data reduction using PCA
%   spm_eeg_spatial_confounds_v2                      - This function defines spatial confounds and adds them to MEEG dataset. 
%   spm_pca_order                                     - Model order selection for PCA   
%   topoplot                                          - plots a topographic map of an EEG or MEG field as a 2-D
%   trig_dev                                          - 
%   unfreezeColors                                    - unfreezeColors  Restore colors of a plot to original indexed color. (v2.3)
%   view_spatial_confounds                            - D = view_spatial_confounds(S);
%   winav_downsample                                  - winav_downsample.m
%   osl_save_nii_stats.old                            - [statsdir,times]=osl_save_nii_stats( Sin )
%   osl_save_nii_stats.old                            - [statsdir,times]=osl_save_nii_stats( Sin )
